package org.wadael.waverobotfrmwrk.simple;

import org.wadael.waverobotfrmwrk.meta.RobotTemplateServlet;

import com.google.wave.api.Blip;


/**
 * Subclass this class to implement a robot 
 * that can modify the blips.
 * 
 * @author jerome baton : Wadael, http://blog.wadael.org
 */
public abstract class BlipModifierRobot extends RobotTemplateServlet {

	@Override
	protected void reactToSubmittedBlip(RobotMessageBundle bundle, Blip blip, Event event) {
		TextView tv = event.getBlip().getDocument() ;
		String eventualNewText = modifyBlipText( tv.getText() ) ;
		if(eventualNewText !=null) 
			tv.replace( eventualNewText  );
	}

	
	/**
	 *	Abstract method you have to implement. 
	 * 
	 * @param actualText the current value of the text in the blip 
	 * @return some other text, to be modified/appended by YOUR code 
	 * OR NULL if you do not want to perform any modification
	 */
	protected abstract String modifyBlipText(String actualText) ;

}
